<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        .flex-container {
            /* display: flex; */
            /* display: flex; 会使容器在块级上下文中表现，默认占据整个父容器的宽度； */
            /* display: inline-flex; */
            /* .inline-flex-container 是一个行内弹性容器，只占据其内容的宽度。 background-color: lightgrey; */
            /* padding: 10px; */
        }


        .flex-container {
            display: flex;
            flex-wrap: wrap;
            /* 允许项目换行 */
            width: 300px;
            height: 200px;
            border: 1px solid #000;
            padding: 10px;
            margin: 10px;
            box-sizing: border-box;
        }

        .flex-item {
            width: 50px;
            height: 50px;
            margin: 5px;
            background-color: lightblue;
            text-align: center;
            line-height: 50px;
            color: #333;
        }

        /* 使用不同的 flex-direction 值来改变项目的排列方向 */

        /* flex-direction: row (默认值) */
        .flex-container.row {
            flex-direction: row;
        }

        /* flex-direction: row-reverse */
        .flex-container.row-reverse {
            flex-direction: row-reverse;
        }

        /* flex-direction: column */
        .flex-container.column {
            flex-direction: column;
        }

        /* flex-direction: column-reverse */
        .flex-container.column-reverse {
            flex-direction: column-reverse;
        }
    </style>
</head>

<body>
    <div class="flex-container">
        <div class="flex-item">Item 1</div>
        <div class="flex-item">Item 2</div>
        <div class="flex-item">Item 3</div>
    </div>

    <!-- 使用 row 方向的 flex 容器 -->
    <div class="flex-container row">
        <div class="flex-item">1</div>
        <div class="flex-item">2</div>
        <div class="flex-item">3</div>
        <div class="flex-item">4</div>
    </div>

    <!-- 使用 row-reverse 方向的 flex 容器 -->
    <div class="flex-container row-reverse">
        <div class="flex-item">1</div>
        <div class="flex-item">2</div>
        <div class="flex-item">3</div>
        <div class="flex-item">4</div>
    </div>

    <!-- 使用 column 方向的 flex 容器 -->
    <div class="flex-container column">
        <div class="flex-item">1</div>
        <div class="flex-item">2</div>
        <div class="flex-item">3</div>
        <div class="flex-item">4</div>
    </div>

    <!-- 使用 column-reverse 方向的 flex 容器 -->
    <div class="flex-container column-reverse">
        <div class="flex-item">1</div>
        <div class="flex-item">2</div>
        <div class="flex-item">3</div>
        <div class="flex-item">4</div>
    </div>
</body>

</html>